package com.codefish.controller;

import java.util.Arrays;

import com.codefish.entity.SysPermissionMenuEntity;
import com.codefish.service.SysPermissionMenuService;
import com.codefish.util.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 菜单
 *
 * @author codefish
 * @email cool_fish@aliyun.com
 * @date 2021-04-15 05:59:48
 */
@RestController
@RequestMapping("/sysPermissionMenu")
public class SysPermissionMenuController {
    @Autowired
    private SysPermissionMenuService sysPermissionMenuService;



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:syspermissionmenu:info")
    public R info(@PathVariable("id") Long id){
		SysPermissionMenuEntity sysPermissionMenu = sysPermissionMenuService.getById(id);

        return R.ok().put("sysPermissionMenu", sysPermissionMenu);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:syspermissionmenu:save")
    public R save(@RequestBody SysPermissionMenuEntity sysPermissionMenu){
		sysPermissionMenuService.save(sysPermissionMenu);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:syspermissionmenu:update")
    public R update(@RequestBody SysPermissionMenuEntity sysPermissionMenu){
		sysPermissionMenuService.updateById(sysPermissionMenu);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:syspermissionmenu:delete")
    public R delete(@RequestBody Long[] ids){
		sysPermissionMenuService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
